package com.pn.controller;

import com.pn.entity.Brand;
import com.pn.entity.Unit;
import com.pn.service.BrandService;
import com.pn.service.UnitService;
import com.pn.utils.PageBean;
import com.pn.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("unit")
public class UnitController {

    @Autowired
    private UnitService unitService;

    //显示单位信息
    @GetMapping("/unit-page-list")
    public Result<PageBean<Unit>> brandPageList(Unit unit){
        PageBean pageBean = unitService.unitPageList(unit);
        return Result.ok(pageBean);
    }

    //修改单位
    @PutMapping("/unit-update")
    public Result unitUpdate(@RequestBody Unit unit){
        return unitService.unitUpdate(unit);
    }


    //添加单位
    @PostMapping("/unit-add")
    public Result unitAdd(@RequestBody Unit unit){
        return unitService.unitAdd(unit);
    }

    //删除单位
    @DeleteMapping("/unit-delete/{unitId}")
    public Result unitDelete(@PathVariable Integer unitId){
        return unitService.unitDelete(unitId);
    }

}
